import json
from models import BaseModels
from sqlalchemy import Column, String, BigInteger, DateTime, Time, ForeignKey, Boolean


class Entering(BaseModels):
    __tablename__ = 'entering'
    id = Column(BigInteger, autoincrement=True, primary_key=True, unique=True, nullable=False)
    facility_id = Column(BigInteger, ForeignKey("facility.id", ondelete='CASCADE'), unique=True, comment="设备ID")
    option = Column(String(64), nullable=True, comment="操作用户")
    code = Column(String(64), nullable=True, comment="物料总码")
    enable = Column(Boolean, nullable=False, comment="物料总码是否可以编辑")

    def __repr__(self):
        return json.dumps({
            "entering_id": self.id,
            "option": self.option,
            "code": self.code
        })
